<template>
  <div class="view-list">
    <div
      class="list-item"
      v-for="l in homelist"
      :key="l.storyId"
      @click="pushroute(l.storyId, l.chapterId, l.chapter_count, l.author,l.img)"
    >
      <div class="item-view">
        <div class="title">{{ l.name }}</div>
        <span class="finish" v-if="l.chapter_count != 1 || l.is_serial == 1">{{
          l.is_serial == 1 ? "连载中" : "已完结"
        }}</span
        ><span class="total" v-if="l.chapter_count != 1 || l.is_serial == 1">{{
          "(更新至" + l.chapter_count + "集)"
        }}</span>
        <img v-lazy="l.img" class="lazyload-img" />
        <div
          class="desc"
          :class="[l.is_serial == 1 ? '' : l.chapter_count == 1 ? 'totop' : '']"
        >
          {{ l.summary }}
        </div>
        <div class="author">
          <img v-lazy="l.user_avatar" class="lazyload-img author-img" />
          {{ l.author }}
        </div>
      </div>
      <div class="has">
        <div class="text" v-if="l.has_text == 1">文</div>
        <div class="audio" v-if="l.has_audio == 1">音</div>
        <div class="vedio" v-if="l.has_video == 1">视</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      name: null,
    };
  },
  components: {},
  props: {
    homelist: Array,
    routename: String,
  },
  methods: {
    pushroute(storyId, chapterId, count, author,img) {
      // if (this.routename == "home") {
      //   this.name = "";
      // } else {
        this.name = this.routename;
      // }

       sessionStorage.setItem('count',count)

      if (count == 1) {
        if (this.$route.name == `/${this.name}story/${this.name}content`) {
          this.$router.go(-1);
        } else {
          this.$router.push({
            name: `${this.name}content`,
          });
        }
        sessionStorage.contentList = JSON.stringify({
          id: chapterId,
          author: author,
        });
      } else {
        if (this.$route.name == `${this.name}/${this.name}story`) {
          this.$router.go(-1);
        } else {
          this.$router.push({
            name: `${this.name}story`,
          });
        }
        sessionStorage.storyList = JSON.stringify({
          id: storyId,
          route: this.name,
          img,
          count
        });
        // localStorage.routeList = JSON.stringify({

        // });
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.view-list {
  position: fixed;
  top: 60px;
  width: 100vw;
  height: 90vh;
  overflow: auto;
  padding-bottom: 50px;
  
  //   background-color: red;
  .list-item {
    position: relative;
    left:45px;
    width: 450px;
    height: 400px;
    margin-bottom: 20px;
    border-radius: 10px;
     box-shadow:
        7px 7px 12px rgba(0, 0, 0, .4),
        -7px -7px 12px rgba(255, 255, 255, .9);
    &::after {
      content: "";
      width: 450px;
      height: 70px;
      position: absolute;
      top: 4%;
      background-color: rgba(151, 135, 135, 0.5);
    }
    img {
      width: 450px;
      height: 400px;
      border-radius: 10px;
      z-index: -1;
    }
    .title {
      font-size: 20px;
      font-weight: 700;
      position: absolute;
      top: 11%;
      left: 6%;
      z-index: 800;
      color: rgb(77, 68, 68);
    }

    .finish {
      background-color: white;
      color: rgb(44, 120, 120);
      font-size: 12px;
      position: absolute;
      top: 22%;
      left: 6%;
      display: inline-block;
      border-radius: 10px;
      height: 15px;
      width: 50px;

      text-align: center;
      line-height: 15px;
      z-index: 800;
    }

    .total {
      position: absolute;
      top: 23%;
      left: 22%;
      font-size: 12px;
      color: rgb(220, 210, 210);
      z-index: 800;
    }
    .desc {
      position: absolute;
      top: 40%;
      left: 0;
      color: rgb(100, 57, 57);
      padding-left: 20px;
      line-height: 20px;
      width: 450px;
      font-size: 15px;
      z-index: 800;

      &.totop {
        position: absolute;
        top: 24%;
      }
    }

    .author {
      position: absolute;
      bottom: 5%;
      left: 8%;
      color: rgb(137, 64, 64);

      .author-img {
        width: 30px;
        height: 30px;
        border-radius: 999px;
        vertical-align: middle;
        margin-right: 10px;
      }
    }
    .has {
      position: absolute;
      bottom: 5%;
      right: 20px;
      color: white;
      display: flex;
      flex-direction: column;
      height: 100px;

      div {
        flex: 1;
      }
    }
  }
}
</style>